import pytest
from selenium import webdriver
from selenium.webdriver.ie.service import Service

from config import BASE_DIR


@pytest.fixture
def driver():
    driver_path=f"{BASE_DIR}/driver/chromedriver.exe"
    services=Service(executable_path=driver_path)
    #无头模式
    options = webdriver.ChromeOptions()
    options.add_argument("--headless")   #无头模式
    options.add_argument("--disable-gpu")#禁用GPU加速
    options.add_argument("--no-sandbox")#禁用沙盒模式
    #禁用插件
    options.add_argument("--disable-extensions")
    driver = webdriver.Chrome(service=services,options= options)
    driver.maximize_window()
    yield driver
    driver.quit()